package com.touni.designpattern.abstractfactorypattern.abfactory;

import com.touni.designpattern.abstractfactorypattern.abfactory.factory.Color;
import com.touni.designpattern.abstractfactorypattern.abfactory.factory.GreenColor;
import com.touni.designpattern.abstractfactorypattern.abfactory.factory.RedColor;
import com.touni.designpattern.abstractfactorypattern.abfactory.factory.Shape;

/**
 * @ClassName : ColorFactory
 * @Description :
 * @Author : lwq
 * @Date: 2020-10-19 09:26
 */
public class ColorFactory extends AbstractFactory{
    @Override
    public Shape getShape(String shapeName) {
        throw new RuntimeException("use error factory!!");
    }

    @Override
     public Color getColor(String colorName) {
        if (colorName == null){
            throw new RuntimeException("colorName must not be null!!");
        }else if (colorName.equalsIgnoreCase("green")){
            return new GreenColor();
        }else if (colorName.equalsIgnoreCase("red")){
            return new RedColor();
        }else {
            throw new RuntimeException("no such color!!");
        }

    }
}
